package com.hhit.bigscreenbackmanage.service.impl.zlgl;

import com.alibaba.fastjson.JSONObject;
import com.hhit.bigscreenbackmanage.dao.zlgl.TZlglQualitySupervisionMapper;
import com.hhit.bigscreenbackmanage.entity.zlgl.TZlglQualitySupervision;
import com.hhit.bigscreenbackmanage.service.zlgl.TZlglQualitySupervisionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

@Service
public class TZlglQualitySupervisionServiceImpl implements TZlglQualitySupervisionService {

    @Autowired
    TZlglQualitySupervisionMapper tZlglQualitySupervisionMapper;

    @Override
    public TZlglQualitySupervision getTZlglQualitySupervision(JSONObject json) {
        return tZlglQualitySupervisionMapper.getTZlglQualitySupervision(json);
    }

    @Override
    public Map<String, Object> insertTZlglQualitySupervision(JSONObject json) {
        Map<String,Object> resultMap = new HashMap<>();
        int result = 0;
        TZlglQualitySupervision supervision = tZlglQualitySupervisionMapper.getTZlglQualitySupervision(json);
        if (supervision == null){
            json.put("id", UUID.randomUUID().toString().replaceAll("-", "").toUpperCase());
            result =  tZlglQualitySupervisionMapper.insertTZlglQualitySupervision(json);
        }else {
            result =  tZlglQualitySupervisionMapper.updateTZlglQualitySupervision(json);
        }
        if (result > 0){
            resultMap.put("flag",true);
        }else {
            resultMap.put("flag",false);
        }
        return resultMap;
    }
}
